feat: 등산 기록 단건 상세 조회 API + 칼로리 계산#160
Conversation
GET /api/hiking-records/{hikingRecordId} 추가. 본인이 참여한 등산 기록의
메타(코스/거리/소요시간/고도/칼로리) 와 함께 PostGIS 의 tracking_points 를
GeoJSON LineString + 점별 고도 배열로 묶고 마일스톤 사진 마커도 함께 반환.
칼로리는 사용자 체중 + 코스 강도(ascent/distance) 기반 MET 공식으로
HikingRecord.fromTrackingSession 시점에 1회 계산해 저장.
체중 미등록 시 65kg 기본값으로 대체.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a detailed view for individual hiking records, providing users with comprehensive insights into their hiking activities. It includes the necessary API infrastructure, data projection, and a new calorie estimation feature to enrich the recorded hiking data. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new API endpoint for retrieving detailed hiking records, including GPS tracks, altitudes, and milestone photos, and implements a calorie calculation utility (CalorieCalculator) based on MET values. The code review feedback suggests optimizing the HikingRecord retrieval with a join fetch query to prevent potential N+1 lazy loading issues when accessing related Mountain and Course entities. Additionally, it recommends adding unit tests for the new calorie calculation logic and the detail retrieval API to cover edge cases.
| public static int calculate( | ||
| Double weightKg, | ||
| Double distanceMeters, | ||
| Double ascentMeters, | ||
| int durationSeconds |
There was a problem hiding this comment.
[P2] 새롭게 추가된 칼로리 계산 로직(CalorieCalculator)과 등산 기록 상세 조회 API에 대한 단위 테스트가 누락되어 있습니다.\n\n### 이유\n칼로리 계산 공식(CalorieCalculator.calculate)은 체중 유무, 등산 강도(MET) 분기 등 다양한 경계 조건(Edge Case)을 포함하고 있으므로, 비즈니스 로직의 정확성을 보장하고 향후 변경 시 오작동을 방지하기 위해 철저한 단위 테스트가 필요합니다.\n\n### 해결 방안\nCalorieCalculatorTest를 추가하여 다음과 같은 시나리오들을 검증하는 테스트 코드를 작성하는 것을 권장합니다:\n- 체중이 없는 경우 기본 체중(65kg)으로 계산되는지 여부\n- 소요 시간이 0 이하일 때 0을 반환하는지 여부\n- 누적 상승고도와 거리 비율에 따라 MET 강도(EASY, MEDIUM, HARD)가 올바르게 판별되는지 여부
- HikingRecord 단건 상세 조회 시 Mountain/Course 를 fetch join 으로 함께 가져와 응답 조립 단계의 LAZY 추가 SELECT 2건을 제거. - 칼로리 기본 체중(65kg) 대체 정책에 향후 개선 방향(성별·나이 추정, 온보딩 단계 입력 강제) TODO 주석 추가.
|
우와오 |
🧾 요약
🔗 이슈
✨ 변경 내용
✅ 확인